/**
 * 
 */
package com.edocbase.desktop.plugins.mdiary;

import static com.edocbase.desktop.plugins.mdiary.MDiaryActionConstants.MDairyActionID.file_driver_up_action;
import static com.edocbase.desktop.plugins.mdiary.MDiaryActionConstants.MDairyActionID.file_edit_cut_action;
import static com.edocbase.desktop.plugins.mdiary.MDiaryActionConstants.MDairyActionID.file_edit_paste_action;

import com.edocbase.desktop.lightweight.widgets.TabItem;
import com.edocbase.desktop.plugins.mdiary.MDiaryActionConstants.MDairyActionID;

;
/**
 * @author X61
 * 
 */
public class SearchTabItemButtonObserver implements ITabItemButtonObserver {

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.edocbase.desktop.plugins.mdairy.ITabItemButtonObserver#active(com
	 * .edocbase.desktop.lightweight.widgets.TabItem,
	 * com.edocbase.desktop.plugins.mdairy.ToolButtonManager)
	 */
	@Override
	public void active(TabItem item, ToolButtonManager buttonManager) {
		ButtonComposite[] buttons = getButtons(buttonManager);
		for (int i = 0; i < buttons.length; i++) {
			ButtonComposite bc = buttons[i];
			bc.setEnabled(false);
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.edocbase.desktop.plugins.mdairy.ITabItemButtonObserver#deactive(com
	 * .edocbase.desktop.lightweight.widgets.TabItem,
	 * com.edocbase.desktop.plugins.mdairy.ToolButtonManager)
	 */
	@Override
	public void deactive(TabItem item, ToolButtonManager buttonManager) {

	}

	protected ButtonComposite[] getButtons(ToolButtonManager buttonManager) {
		return buttonManager.getButtons(MDairyActionID.file_edit_copy_action
				.name(), file_edit_cut_action.name(), file_edit_paste_action
				.name(), file_driver_up_action.name());
	}

}
